package cn.cmvideo.xworld.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import cn.cmvideo.xworld.R;
import cn.cmvideo.xworld.model.Comment;

public class CommentAdapter extends BaseAdapter {
	
	private LayoutInflater mlnflater;
	private List<Comment> list = null;
	
	public CommentAdapter(Context context, List<Comment> list){
		this.mlnflater = LayoutInflater.from(context);
		this.list = list;
	}

	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public Object getItem(int arg0) {
		return null;
	}

	@Override
	public long getItemId(int arg0) {
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		Comment comment = list.get(position);
		convertView = mlnflater.inflate(R.layout.item_comment, null);
		TextView mobile = (TextView) convertView.findViewById(R.id.mobile);
		TextView checkTime = (TextView) convertView.findViewById(R.id.checkTime);
		TextView content = (TextView) convertView.findViewById(R.id.content);
		mobile.setText(changeMobile(comment.mobile));
		checkTime.setText(comment.checkTime);
		content.setText(comment.content);
		return convertView;
	}
	
	private String changeMobile(String s){
		char[] chars = s.toCharArray();
		return String.valueOf(chars, 0, 3) + "*****" + String.valueOf(chars, chars.length - 3, 3);
	}

}
